using System;
using System.Data;
using System.Data.OleDb;
using System.Collections;
using System.Configuration;
using PCSComUtils.DataAccess;
using PCSComUtils.PCSExc;
using PCSComUtils.Common;
using System.Runtime.InteropServices;
namespace PCSComMaterials.Inventory.DS
{
	public class IV_MRBResultDS 
	{
		public IV_MRBResultDS()
		{
		}
		private const string THIS = "PCSComMaterials.Inventory.DS.IV_MRBResultDS";

	
		///    <summary>
		///       This method uses to add data to IV_MRBResult
		///    </summary>
		///    <Inputs>
		///        IV_MRBResultVO       
		///    </Inputs>
		///    <Returns>
		///       void
		///    </Returns>
		///    <History>
		///       Friday, July 29, 2005
		///    </History>


		public void Add(object pobjObjectVO)
		{
			const string METHOD_NAME = THIS + ".Add()";
			 
			OleDbConnection oconPCS =null;
			OleDbCommand ocmdPCS =null;
			try
			{
				IV_MRBResultVO objObject = (IV_MRBResultVO) pobjObjectVO;
				string strSql = String.Empty;
				
				oconPCS = new OleDbConnection(Utils.Instance.OleDbConnectionString);
				ocmdPCS = new OleDbCommand("", oconPCS);
				
				strSql=	"INSERT INTO IV_MRBResult("
					+ IV_MRBResultTable.MRBRESULTID_FLD + ","
					+ IV_MRBResultTable.MRBNO_FLD + ","
					+ IV_MRBResultTable.CCNID_FLD + ","
					+ IV_MRBResultTable.LOT_FLD + ","
					+ IV_MRBResultTable.SERIAL_FLD + ","
					+ IV_MRBResultTable.LOCATIONID_FLD + ","
					+ IV_MRBResultTable.BINID_FLD + ","
					+ IV_MRBResultTable.POSTDATE_FLD + ","
					+ IV_MRBResultTable.COMMENT_FLD + ","
					+ IV_MRBResultTable.USEASISQUANTITY_FLD + ","
					+ IV_MRBResultTable.RTVQUANTITY_FLD + ","
					+ IV_MRBResultTable.RTVREPLACEQUANTITY_FLD + ","
					+ IV_MRBResultTable.RTVREWORKQUANTITY_FLD + ","
					+ IV_MRBResultTable.REWORKMFGQUANTITY_FLD + ","
					+ IV_MRBResultTable.SCRAPQUANTITY_FLD + ","
					+ IV_MRBResultTable.USEASISBINID_FLD + ","
					+ IV_MRBResultTable.RTVBINID_FLD + ","
					+ IV_MRBResultTable.RTVREPLACEBINID_FLD + ","
					+ IV_MRBResultTable.RTVREWORKBINID_FLD + ","
					+ IV_MRBResultTable.REWORKMFGBINID_FLD + ","
					+ IV_MRBResultTable.SCRAPBINID_FLD + ","
					+ IV_MRBResultTable.REWORKPURBINID_FLD + ","
					+ IV_MRBResultTable.USEASISLOCID_FLD + ","
					+ IV_MRBResultTable.RTVLOCID_FLD + ","
					+ IV_MRBResultTable.RTVREPLACELOCID_FLD + ","
					+ IV_MRBResultTable.RTVREWORKLOCID_FLD + ","
					+ IV_MRBResultTable.REWORKMFGLOCID_FLD + ","
					+ IV_MRBResultTable.SCRAPLOCID_FLD + ","
					+ IV_MRBResultTable.REWORKPURLOCID_FLD + ","
					+ IV_MRBResultTable.STOCKUMID_FLD + ","
					+ IV_MRBResultTable.PRODUCTID_FLD + ")"
					+ "VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_MRBResultTable.MRBRESULTID_FLD, OleDbType.Integer));
				ocmdPCS.Parameters[IV_MRBResultTable.MRBRESULTID_FLD].Value = objObject.MRBResultID;

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_MRBResultTable.MRBNO_FLD, OleDbType.VarWChar));
				ocmdPCS.Parameters[IV_MRBResultTable.MRBNO_FLD].Value = objObject.MRBNo;

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_MRBResultTable.CCNID_FLD, OleDbType.Integer));
				ocmdPCS.Parameters[IV_MRBResultTable.CCNID_FLD].Value = objObject.CCNID;

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_MRBResultTable.LOT_FLD, OleDbType.VarWChar));
				ocmdPCS.Parameters[IV_MRBResultTable.LOT_FLD].Value = objObject.Lot;

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_MRBResultTable.SERIAL_FLD, OleDbType.VarWChar));
				ocmdPCS.Parameters[IV_MRBResultTable.SERIAL_FLD].Value = objObject.Serial;

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_MRBResultTable.LOCATIONID_FLD, OleDbType.Integer));
				ocmdPCS.Parameters[IV_MRBResultTable.LOCATIONID_FLD].Value = objObject.LocationID;

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_MRBResultTable.BINID_FLD, OleDbType.Integer));
				ocmdPCS.Parameters[IV_MRBResultTable.BINID_FLD].Value = objObject.BinID;

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_MRBResultTable.POSTDATE_FLD, OleDbType.Date));
				ocmdPCS.Parameters[IV_MRBResultTable.POSTDATE_FLD].Value = objObject.PostDate;

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_MRBResultTable.COMMENT_FLD, OleDbType.VarWChar));
				ocmdPCS.Parameters[IV_MRBResultTable.COMMENT_FLD].Value = objObject.Comment;

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_MRBResultTable.USEASISQUANTITY_FLD, OleDbType.Decimal));
				ocmdPCS.Parameters[IV_MRBResultTable.USEASISQUANTITY_FLD].Value = objObject.UseAsIsQuantity;

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_MRBResultTable.RTVQUANTITY_FLD, OleDbType.Decimal));
				ocmdPCS.Parameters[IV_MRBResultTable.RTVQUANTITY_FLD].Value = objObject.RTVQuantity;

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_MRBResultTable.RTVREPLACEQUANTITY_FLD, OleDbType.Decimal));
				ocmdPCS.Parameters[IV_MRBResultTable.RTVREPLACEQUANTITY_FLD].Value = objObject.RTVReplaceQuantity;

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_MRBResultTable.RTVREWORKQUANTITY_FLD, OleDbType.Decimal));
				ocmdPCS.Parameters[IV_MRBResultTable.RTVREWORKQUANTITY_FLD].Value = objObject.RTVReworkQuantity;

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_MRBResultTable.REWORKMFGQUANTITY_FLD, OleDbType.Decimal));
				ocmdPCS.Parameters[IV_MRBResultTable.REWORKMFGQUANTITY_FLD].Value = objObject.ReworkMfgQuantity;

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_MRBResultTable.SCRAPQUANTITY_FLD, OleDbType.Decimal));
				ocmdPCS.Parameters[IV_MRBResultTable.SCRAPQUANTITY_FLD].Value = objObject.ScrapQuantity;

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_MRBResultTable.USEASISBINID_FLD, OleDbType.Integer));
				ocmdPCS.Parameters[IV_MRBResultTable.USEASISBINID_FLD].Value = objObject.UseAsIsBinID;

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_MRBResultTable.RTVBINID_FLD, OleDbType.Integer));
				ocmdPCS.Parameters[IV_MRBResultTable.RTVBINID_FLD].Value = objObject.RTVBinID;

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_MRBResultTable.RTVREPLACEBINID_FLD, OleDbType.Integer));
				ocmdPCS.Parameters[IV_MRBResultTable.RTVREPLACEBINID_FLD].Value = objObject.RTVReplaceBinID;

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_MRBResultTable.RTVREWORKBINID_FLD, OleDbType.Integer));
				ocmdPCS.Parameters[IV_MRBResultTable.RTVREWORKBINID_FLD].Value = objObject.RTVReworkBinID;

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_MRBResultTable.REWORKMFGBINID_FLD, OleDbType.Integer));
				ocmdPCS.Parameters[IV_MRBResultTable.REWORKMFGBINID_FLD].Value = objObject.ReworkMfgBinID;

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_MRBResultTable.SCRAPBINID_FLD, OleDbType.Integer));
				ocmdPCS.Parameters[IV_MRBResultTable.SCRAPBINID_FLD].Value = objObject.ScrapBinID;

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_MRBResultTable.REWORKPURBINID_FLD, OleDbType.Integer));
				ocmdPCS.Parameters[IV_MRBResultTable.REWORKPURBINID_FLD].Value = objObject.ReworkPurBinID;

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_MRBResultTable.USEASISLOCID_FLD, OleDbType.Integer));
				ocmdPCS.Parameters[IV_MRBResultTable.USEASISLOCID_FLD].Value = objObject.UseAsIsLocID;

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_MRBResultTable.RTVLOCID_FLD, OleDbType.Integer));
				ocmdPCS.Parameters[IV_MRBResultTable.RTVLOCID_FLD].Value = objObject.RTVLocID;

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_MRBResultTable.RTVREPLACELOCID_FLD, OleDbType.Integer));
				ocmdPCS.Parameters[IV_MRBResultTable.RTVREPLACELOCID_FLD].Value = objObject.RTVReplaceLocID;

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_MRBResultTable.RTVREWORKLOCID_FLD, OleDbType.Integer));
				ocmdPCS.Parameters[IV_MRBResultTable.RTVREWORKLOCID_FLD].Value = objObject.RTVReworkLocID;

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_MRBResultTable.REWORKMFGLOCID_FLD, OleDbType.Integer));
				ocmdPCS.Parameters[IV_MRBResultTable.REWORKMFGLOCID_FLD].Value = objObject.ReworkMfgLocID;

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_MRBResultTable.SCRAPLOCID_FLD, OleDbType.Integer));
				ocmdPCS.Parameters[IV_MRBResultTable.SCRAPLOCID_FLD].Value = objObject.ScrapLocID;

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_MRBResultTable.REWORKPURLOCID_FLD, OleDbType.Integer));
				ocmdPCS.Parameters[IV_MRBResultTable.REWORKPURLOCID_FLD].Value = objObject.ReworkPurLocID;

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_MRBResultTable.STOCKUMID_FLD, OleDbType.Integer));
				ocmdPCS.Parameters[IV_MRBResultTable.STOCKUMID_FLD].Value = objObject.StockUMID;

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_MRBResultTable.PRODUCTID_FLD, OleDbType.Integer));
				ocmdPCS.Parameters[IV_MRBResultTable.PRODUCTID_FLD].Value = objObject.ProductID;


				
				ocmdPCS.CommandText = strSql;
				ocmdPCS.Connection.Open();
				ocmdPCS.ExecuteNonQuery();	

			}
			catch(OleDbException ex)
			{
				if (ex.Errors[1].NativeError == ErrorCode.SQLDUPLICATE_KEYCODE)
				{
																   
					throw new PCSDBException(ErrorCode.DUPLICATE_KEY, METHOD_NAME, ex);				
				}
				else
				{
					throw new PCSDBException(ErrorCode.ERROR_DB, METHOD_NAME,ex);
				}
			}			

			catch(InvalidOperationException ex)
			{
				throw new PCSDBException(ErrorCode.ERROR_DB, METHOD_NAME,ex);
			}
			catch (Exception ex) 
			{
				throw new PCSDBException(ErrorCode.OTHER_ERROR, METHOD_NAME, ex);
			}

			finally 
			{
				if (oconPCS!=null) 
				{
					if (oconPCS.State != ConnectionState.Closed) 
					{
						oconPCS.Close();
					}
				}
			}
		}
	

		///    <summary>
		///       This method uses to add data to IV_MRBResult
		///    </summary>
		///    <Inputs>
		///        IV_MRBResultVO       
		///    </Inputs>
		///    <Returns>
		///       void
		///    </Returns>
		///    <History>
		///       Friday, July 29, 2005
		///    </History>


		public int AddAndReturnID(object pobjObjectVO)
		{
			const string METHOD_NAME = THIS + ".AddAndReturnID()";
			 
			OleDbConnection oconPCS =null;
			OleDbCommand ocmdPCS =null;
			try
			{
				IV_MRBResultVO objObject = (IV_MRBResultVO) pobjObjectVO;
				string strSql = String.Empty;
				
				oconPCS = new OleDbConnection(Utils.Instance.OleDbConnectionString);
				ocmdPCS = new OleDbCommand("", oconPCS);
				
				strSql=	"INSERT INTO IV_MRBResult("
					+ IV_MRBResultTable.MRBNO_FLD + ","
					+ IV_MRBResultTable.CCNID_FLD + ","
					+ IV_MRBResultTable.LOT_FLD + ","
					+ IV_MRBResultTable.SERIAL_FLD + ","
					+ IV_MRBResultTable.LOCATIONID_FLD + ","
					+ IV_MRBResultTable.BINID_FLD + ","
					+ IV_MRBResultTable.POSTDATE_FLD + ","
					+ IV_MRBResultTable.COMMENT_FLD + ","
					+ IV_MRBResultTable.USEASISQUANTITY_FLD + ","
					+ IV_MRBResultTable.RTVQUANTITY_FLD + ","
					+ IV_MRBResultTable.RTVREPLACEQUANTITY_FLD + ","
					+ IV_MRBResultTable.RTVREWORKQUANTITY_FLD + ","
					+ IV_MRBResultTable.REWORKMFGQUANTITY_FLD + ","
					+ IV_MRBResultTable.REWORKPURQUANTITY_FLD + ","
					+ IV_MRBResultTable.SCRAPQUANTITY_FLD + ","
					+ IV_MRBResultTable.USEASISBINID_FLD + ","
					+ IV_MRBResultTable.RTVBINID_FLD + ","
					+ IV_MRBResultTable.RTVREPLACEBINID_FLD + ","
					+ IV_MRBResultTable.RTVREWORKBINID_FLD + ","
					+ IV_MRBResultTable.REWORKMFGBINID_FLD + ","
					+ IV_MRBResultTable.SCRAPBINID_FLD + ","
					+ IV_MRBResultTable.REWORKPURBINID_FLD + ","
					+ IV_MRBResultTable.USEASISLOCID_FLD + ","
					+ IV_MRBResultTable.RTVLOCID_FLD + ","
					+ IV_MRBResultTable.RTVREPLACELOCID_FLD + ","
					+ IV_MRBResultTable.RTVREWORKLOCID_FLD + ","
					+ IV_MRBResultTable.REWORKMFGLOCID_FLD + ","
					+ IV_MRBResultTable.SCRAPLOCID_FLD + ","
					+ IV_MRBResultTable.REWORKPURLOCID_FLD + ","
					+ IV_MRBResultTable.STOCKUMID_FLD + ","
					+ IV_MRBResultTable.PRODUCTID_FLD + ","
					+ IV_MRBResultTable.MASTERLOCATIONID_FLD + ")"
					+ "VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) SELECT @@IDENTITY";

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_MRBResultTable.MRBNO_FLD, OleDbType.VarWChar));
				ocmdPCS.Parameters[IV_MRBResultTable.MRBNO_FLD].Value = objObject.MRBNo;

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_MRBResultTable.CCNID_FLD, OleDbType.Integer));
				ocmdPCS.Parameters[IV_MRBResultTable.CCNID_FLD].Value = objObject.CCNID;

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_MRBResultTable.LOT_FLD, OleDbType.VarWChar));
				ocmdPCS.Parameters[IV_MRBResultTable.LOT_FLD].Value = objObject.Lot;

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_MRBResultTable.SERIAL_FLD, OleDbType.VarWChar));
				ocmdPCS.Parameters[IV_MRBResultTable.SERIAL_FLD].Value = objObject.Serial;

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_MRBResultTable.LOCATIONID_FLD, OleDbType.Integer));
				ocmdPCS.Parameters[IV_MRBResultTable.LOCATIONID_FLD].Value = objObject.LocationID;

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_MRBResultTable.BINID_FLD, OleDbType.Integer));
				if (objObject.BinID > 0)
				{
					ocmdPCS.Parameters[IV_MRBResultTable.BINID_FLD].Value = objObject.BinID;
				}
				else ocmdPCS.Parameters[IV_MRBResultTable.BINID_FLD].Value = DBNull.Value;

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_MRBResultTable.POSTDATE_FLD, OleDbType.Date));
				ocmdPCS.Parameters[IV_MRBResultTable.POSTDATE_FLD].Value = objObject.PostDate;

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_MRBResultTable.COMMENT_FLD, OleDbType.VarWChar));
				ocmdPCS.Parameters[IV_MRBResultTable.COMMENT_FLD].Value = objObject.Comment;

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_MRBResultTable.USEASISQUANTITY_FLD, OleDbType.Decimal));
				if (objObject.UseAsIsQuantity > 0)
				{
					ocmdPCS.Parameters[IV_MRBResultTable.USEASISQUANTITY_FLD].Value = objObject.UseAsIsQuantity;
				}
				else ocmdPCS.Parameters[IV_MRBResultTable.USEASISQUANTITY_FLD].Value = DBNull.Value;

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_MRBResultTable.RTVQUANTITY_FLD, OleDbType.Decimal));
				if (objObject.RTVQuantity > 0)
				{
					ocmdPCS.Parameters[IV_MRBResultTable.RTVQUANTITY_FLD].Value = objObject.RTVQuantity;
				}
				else ocmdPCS.Parameters[IV_MRBResultTable.RTVQUANTITY_FLD].Value = DBNull.Value;

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_MRBResultTable.RTVREPLACEQUANTITY_FLD, OleDbType.Decimal));
				if (objObject.RTVReplaceQuantity > 0)
				{
					ocmdPCS.Parameters[IV_MRBResultTable.RTVREPLACEQUANTITY_FLD].Value = objObject.RTVReplaceQuantity;
				}
				else ocmdPCS.Parameters[IV_MRBResultTable.RTVREPLACEQUANTITY_FLD].Value = DBNull.Value;

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_MRBResultTable.RTVREWORKQUANTITY_FLD, OleDbType.Decimal));
				if (objObject.RTVReworkQuantity > 0)
				{
					ocmdPCS.Parameters[IV_MRBResultTable.RTVREWORKQUANTITY_FLD].Value = objObject.RTVReworkQuantity;
				}
				else ocmdPCS.Parameters[IV_MRBResultTable.RTVREWORKQUANTITY_FLD].Value = DBNull.Value;

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_MRBResultTable.REWORKMFGQUANTITY_FLD, OleDbType.Decimal));
				if (objObject.ReworkMfgQuantity > 0)
				{
					ocmdPCS.Parameters[IV_MRBResultTable.REWORKMFGQUANTITY_FLD].Value = objObject.ReworkMfgQuantity;
				}
				else ocmdPCS.Parameters[IV_MRBResultTable.REWORKMFGQUANTITY_FLD].Value = DBNull.Value;

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_MRBResultTable.REWORKPURQUANTITY_FLD, OleDbType.Decimal));
				if (objObject.ReworkPurQuantity > 0)
				{
					ocmdPCS.Parameters[IV_MRBResultTable.REWORKPURQUANTITY_FLD].Value = objObject.ReworkPurQuantity;
				}
				else ocmdPCS.Parameters[IV_MRBResultTable.REWORKPURQUANTITY_FLD].Value = DBNull.Value;

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_MRBResultTable.SCRAPQUANTITY_FLD, OleDbType.Decimal));
				if (objObject.ScrapQuantity > 0)
				{
					ocmdPCS.Parameters[IV_MRBResultTable.SCRAPQUANTITY_FLD].Value = objObject.ScrapQuantity;
				}
				else ocmdPCS.Parameters[IV_MRBResultTable.SCRAPQUANTITY_FLD].Value = DBNull.Value;

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_MRBResultTable.USEASISBINID_FLD, OleDbType.Integer));
				if (objObject.UseAsIsBinID > 0)
				{
					ocmdPCS.Parameters[IV_MRBResultTable.USEASISBINID_FLD].Value = objObject.UseAsIsBinID;
				}
				else ocmdPCS.Parameters[IV_MRBResultTable.USEASISBINID_FLD].Value = DBNull.Value;

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_MRBResultTable.RTVBINID_FLD, OleDbType.Integer));
				if (objObject.RTVBinID > 0)
				{
					ocmdPCS.Parameters[IV_MRBResultTable.RTVBINID_FLD].Value = objObject.RTVBinID;
				}
				else ocmdPCS.Parameters[IV_MRBResultTable.RTVBINID_FLD].Value = DBNull.Value;

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_MRBResultTable.RTVREPLACEBINID_FLD, OleDbType.Integer));
				if (objObject.RTVReplaceBinID > 0)
				{
					ocmdPCS.Parameters[IV_MRBResultTable.RTVREPLACEBINID_FLD].Value = objObject.RTVReplaceBinID;
				}
				else ocmdPCS.Parameters[IV_MRBResultTable.RTVREPLACEBINID_FLD].Value = DBNull.Value;

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_MRBResultTable.RTVREWORKBINID_FLD, OleDbType.Integer));
				if (objObject.RTVReworkBinID > 0)
				{
					ocmdPCS.Parameters[IV_MRBResultTable.RTVREWORKBINID_FLD].Value = objObject.RTVReworkBinID;
				}
				else ocmdPCS.Parameters[IV_MRBResultTable.RTVREWORKBINID_FLD].Value = DBNull.Value;

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_MRBResultTable.REWORKMFGBINID_FLD, OleDbType.Integer));
				if (objObject.ReworkMfgBinID > 0)
				{
					ocmdPCS.Parameters[IV_MRBResultTable.REWORKMFGBINID_FLD].Value = objObject.ReworkMfgBinID;
				}
				else ocmdPCS.Parameters[IV_MRBResultTable.REWORKMFGBINID_FLD].Value = DBNull.Value;

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_MRBResultTable.SCRAPBINID_FLD, OleDbType.Integer));
				if (objObject.ScrapBinID > 0)
				{
					ocmdPCS.Parameters[IV_MRBResultTable.SCRAPBINID_FLD].Value = objObject.ScrapBinID;
				}
				else ocmdPCS.Parameters[IV_MRBResultTable.SCRAPBINID_FLD].Value = DBNull.Value;

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_MRBResultTable.REWORKPURBINID_FLD, OleDbType.Integer));
				if (objObject.ReworkPurBinID > 0)
				{
					ocmdPCS.Parameters[IV_MRBResultTable.REWORKPURBINID_FLD].Value = objObject.ReworkPurBinID;
				}
				else ocmdPCS.Parameters[IV_MRBResultTable.REWORKPURBINID_FLD].Value = DBNull.Value;

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_MRBResultTable.USEASISLOCID_FLD, OleDbType.Integer));
				if (objObject.UseAsIsLocID > 0)
				{
					ocmdPCS.Parameters[IV_MRBResultTable.USEASISLOCID_FLD].Value = objObject.UseAsIsLocID;
				}
				else ocmdPCS.Parameters[IV_MRBResultTable.USEASISLOCID_FLD].Value = DBNull.Value;

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_MRBResultTable.RTVLOCID_FLD, OleDbType.Integer));
				if (objObject.RTVLocID > 0)
				{
					ocmdPCS.Parameters[IV_MRBResultTable.RTVLOCID_FLD].Value = objObject.RTVLocID;
				}
				else ocmdPCS.Parameters[IV_MRBResultTable.RTVLOCID_FLD].Value = DBNull.Value;

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_MRBResultTable.RTVREPLACELOCID_FLD, OleDbType.Integer));
				if (objObject.RTVReplaceLocID > 0)
				{
					ocmdPCS.Parameters[IV_MRBResultTable.RTVREPLACELOCID_FLD].Value = objObject.RTVReplaceLocID;
				}
				else ocmdPCS.Parameters[IV_MRBResultTable.RTVREPLACELOCID_FLD].Value = DBNull.Value;

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_MRBResultTable.RTVREWORKLOCID_FLD, OleDbType.Integer));
				if (objObject.RTVReworkLocID > 0)
				{
					ocmdPCS.Parameters[IV_MRBResultTable.RTVREWORKLOCID_FLD].Value = objObject.RTVReworkLocID;
				}
				else ocmdPCS.Parameters[IV_MRBResultTable.RTVREWORKLOCID_FLD].Value = DBNull.Value;

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_MRBResultTable.REWORKMFGLOCID_FLD, OleDbType.Integer));
				if (objObject.ReworkMfgLocID > 0)
				{
					ocmdPCS.Parameters[IV_MRBResultTable.REWORKMFGLOCID_FLD].Value = objObject.ReworkMfgLocID;
				}
				else ocmdPCS.Parameters[IV_MRBResultTable.REWORKMFGLOCID_FLD].Value = DBNull.Value;

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_MRBResultTable.SCRAPLOCID_FLD, OleDbType.Integer));
				if (objObject.ScrapLocID > 0)
				{
					ocmdPCS.Parameters[IV_MRBResultTable.SCRAPLOCID_FLD].Value = objObject.ScrapLocID;
				}
				else ocmdPCS.Parameters[IV_MRBResultTable.SCRAPLOCID_FLD].Value = DBNull.Value;

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_MRBResultTable.REWORKPURLOCID_FLD, OleDbType.Integer));
				if (objObject.ReworkPurLocID > 0)
				{
					ocmdPCS.Parameters[IV_MRBResultTable.REWORKPURLOCID_FLD].Value = objObject.ReworkPurLocID;
				}
				else ocmdPCS.Parameters[IV_MRBResultTable.REWORKPURLOCID_FLD].Value = DBNull.Value;

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_MRBResultTable.STOCKUMID_FLD, OleDbType.Integer));
				ocmdPCS.Parameters[IV_MRBResultTable.STOCKUMID_FLD].Value = objObject.StockUMID;

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_MRBResultTable.PRODUCTID_FLD, OleDbType.Integer));
				ocmdPCS.Parameters[IV_MRBResultTable.PRODUCTID_FLD].Value = objObject.ProductID;

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_MRBResultTable.MASTERLOCATIONID_FLD, OleDbType.Integer));
				ocmdPCS.Parameters[IV_MRBResultTable.MASTERLOCATIONID_FLD].Value = objObject.MasterLocationID;
				
				ocmdPCS.CommandText = strSql;
				ocmdPCS.Connection.Open();
				object objResult = ocmdPCS.ExecuteScalar();	
				oconPCS.Close();
				if ((objResult != null) && (objResult != DBNull.Value))
				{
					return int.Parse(objResult.ToString());
				}
				return 0;
			}
			catch(OleDbException ex)
			{
				if (ex.Errors[1].NativeError == ErrorCode.SQLDUPLICATE_KEYCODE)
				{
																   
					throw new PCSDBException(ErrorCode.DUPLICATE_KEY, METHOD_NAME, ex);				
				}
				else
				{
					throw new PCSDBException(ErrorCode.ERROR_DB, METHOD_NAME,ex);
				}
			}			

			catch(InvalidOperationException ex)
			{
				throw new PCSDBException(ErrorCode.ERROR_DB, METHOD_NAME,ex);
			}
			catch (Exception ex) 
			{
				throw new PCSDBException(ErrorCode.OTHER_ERROR, METHOD_NAME, ex);
			}

			finally 
			{
				if (oconPCS!=null) 
				{
					if (oconPCS.State != ConnectionState.Closed) 
					{
						oconPCS.Close();
					}
				}
			}
		}
	

		///    <summary>
		///       This method uses to add data to IV_MRBResult
		///    </summary>
		///    <Inputs>
		///        IV_MRBResultVO       
		///    </Inputs>
		///    <Returns>
		///       void
		///    </Returns>
		///    <History>
		///       Friday, July 29, 2005
		///    </History>

		public void Delete(int pintID)
		{
			const string METHOD_NAME = THIS + ".Delete()";
			string strSql = String.Empty;
			strSql=	"DELETE " + IV_MRBResultTable.TABLE_NAME + " WHERE  " + "MasterLocationID" + "=" + pintID.ToString();
			OleDbConnection oconPCS=null;
			OleDbCommand ocmdPCS =null;
			try
			{
				
				oconPCS = new OleDbConnection(Utils.Instance.OleDbConnectionString);
				ocmdPCS = new OleDbCommand(strSql, oconPCS);

				ocmdPCS.Connection.Open();
				ocmdPCS.ExecuteNonQuery();	
				ocmdPCS = null;

			}
			catch(OleDbException ex)
			{
				if (ex.Errors[1].NativeError == ErrorCode.SQLCASCADE_PREVENT_KEYCODE)
				{
																   
					throw new PCSDBException(ErrorCode.CASCADE_DELETE_PREVENT, METHOD_NAME, ex);				
				}
				else
				{
					throw new PCSDBException(ErrorCode.ERROR_DB, METHOD_NAME,ex);
				}
			}			

			catch (Exception ex) 
			{
				throw new PCSDBException(ErrorCode.OTHER_ERROR, METHOD_NAME, ex);
			}



			finally 
			{
				if (oconPCS!=null) 
				{
					if (oconPCS.State != ConnectionState.Closed) 
					{
						oconPCS.Close();
					}
				}
			}
		}
	

		///    <summary>
		///       This method uses to add data to IV_MRBResult
		///    </summary>
		///    <Inputs>
		///        IV_MRBResultVO       
		///    </Inputs>
		///    <Returns>
		///       void
		///    </Returns>
		///    <History>
		///       Friday, July 29, 2005
		///    </History>

		public object GetObjectVO(int pintID)
		{
			const string METHOD_NAME = THIS + ".GetObjectVO()";
			DataSet dstPCS = new DataSet();
			
			OleDbDataReader odrPCS = null;
			OleDbConnection oconPCS = null;
			OleDbCommand ocmdPCS = null;
			try 
			{
				string strSql = String.Empty;
				strSql=	"SELECT "
					+ IV_MRBResultTable.MASTERLOCATIONID_FLD + ","
					+ IV_MRBResultTable.MRBRESULTID_FLD + ","
					+ IV_MRBResultTable.MRBNO_FLD + ","
					+ IV_MRBResultTable.CCNID_FLD + ","
					+ IV_MRBResultTable.LOT_FLD + ","
					+ IV_MRBResultTable.SERIAL_FLD + ","
					+ IV_MRBResultTable.LOCATIONID_FLD + ","
					+ IV_MRBResultTable.BINID_FLD + ","
					+ IV_MRBResultTable.POSTDATE_FLD + ","
					+ IV_MRBResultTable.COMMENT_FLD + ","
					+ IV_MRBResultTable.USEASISQUANTITY_FLD + ","
					+ IV_MRBResultTable.RTVQUANTITY_FLD + ","
					+ IV_MRBResultTable.RTVREPLACEQUANTITY_FLD + ","
					+ IV_MRBResultTable.RTVREWORKQUANTITY_FLD + ","
					+ IV_MRBResultTable.REWORKMFGQUANTITY_FLD + ","
					+ IV_MRBResultTable.SCRAPQUANTITY_FLD + ","
					+ IV_MRBResultTable.USEASISBINID_FLD + ","
					+ IV_MRBResultTable.RTVBINID_FLD + ","
					+ IV_MRBResultTable.RTVREPLACEBINID_FLD + ","
					+ IV_MRBResultTable.RTVREWORKBINID_FLD + ","
					+ IV_MRBResultTable.REWORKMFGBINID_FLD + ","
					+ IV_MRBResultTable.SCRAPBINID_FLD + ","
					+ IV_MRBResultTable.REWORKPURBINID_FLD + ","
					+ IV_MRBResultTable.USEASISLOCID_FLD + ","
					+ IV_MRBResultTable.RTVLOCID_FLD + ","
					+ IV_MRBResultTable.RTVREPLACELOCID_FLD + ","
					+ IV_MRBResultTable.RTVREWORKLOCID_FLD + ","
					+ IV_MRBResultTable.REWORKMFGLOCID_FLD + ","
					+ IV_MRBResultTable.SCRAPLOCID_FLD + ","
					+ IV_MRBResultTable.REWORKPURLOCID_FLD + ","
					+ IV_MRBResultTable.STOCKUMID_FLD + ","
					+ IV_MRBResultTable.PRODUCTID_FLD
					+ " FROM " + IV_MRBResultTable.TABLE_NAME
					+" WHERE " + IV_MRBResultTable.MASTERLOCATIONID_FLD + "=" + pintID;

				
				oconPCS = new OleDbConnection(Utils.Instance.OleDbConnectionString);
				ocmdPCS = new OleDbCommand(strSql, oconPCS);

				ocmdPCS.Connection.Open();
				odrPCS = ocmdPCS.ExecuteReader();

				IV_MRBResultVO objObject = new IV_MRBResultVO();

				while (odrPCS.Read())
				{ 
					objObject.MasterLocationID = int.Parse(odrPCS[IV_MRBResultTable.MASTERLOCATIONID_FLD].ToString().Trim());
					objObject.MRBResultID = int.Parse(odrPCS[IV_MRBResultTable.MRBRESULTID_FLD].ToString().Trim());
					objObject.MRBNo = odrPCS[IV_MRBResultTable.MRBNO_FLD].ToString().Trim();
					objObject.CCNID = int.Parse(odrPCS[IV_MRBResultTable.CCNID_FLD].ToString().Trim());
					objObject.Lot = odrPCS[IV_MRBResultTable.LOT_FLD].ToString().Trim();
					objObject.Serial = odrPCS[IV_MRBResultTable.SERIAL_FLD].ToString().Trim();
					objObject.LocationID = int.Parse(odrPCS[IV_MRBResultTable.LOCATIONID_FLD].ToString().Trim());
					objObject.BinID = int.Parse(odrPCS[IV_MRBResultTable.BINID_FLD].ToString().Trim());
					objObject.PostDate = DateTime.Parse(odrPCS[IV_MRBResultTable.POSTDATE_FLD].ToString().Trim());
					objObject.Comment = odrPCS[IV_MRBResultTable.COMMENT_FLD].ToString().Trim();
					objObject.UseAsIsQuantity = Decimal.Parse(odrPCS[IV_MRBResultTable.USEASISQUANTITY_FLD].ToString().Trim());
					objObject.RTVQuantity = Decimal.Parse(odrPCS[IV_MRBResultTable.RTVQUANTITY_FLD].ToString().Trim());
					objObject.RTVReplaceQuantity = Decimal.Parse(odrPCS[IV_MRBResultTable.RTVREPLACEQUANTITY_FLD].ToString().Trim());
					objObject.RTVReworkQuantity = Decimal.Parse(odrPCS[IV_MRBResultTable.RTVREWORKQUANTITY_FLD].ToString().Trim());
					objObject.ReworkMfgQuantity = Decimal.Parse(odrPCS[IV_MRBResultTable.REWORKMFGQUANTITY_FLD].ToString().Trim());
					objObject.ScrapQuantity = Decimal.Parse(odrPCS[IV_MRBResultTable.SCRAPQUANTITY_FLD].ToString().Trim());
					objObject.UseAsIsBinID = int.Parse(odrPCS[IV_MRBResultTable.USEASISBINID_FLD].ToString().Trim());
					objObject.RTVBinID = int.Parse(odrPCS[IV_MRBResultTable.RTVBINID_FLD].ToString().Trim());
					objObject.RTVReplaceBinID = int.Parse(odrPCS[IV_MRBResultTable.RTVREPLACEBINID_FLD].ToString().Trim());
					objObject.RTVReworkBinID = int.Parse(odrPCS[IV_MRBResultTable.RTVREWORKBINID_FLD].ToString().Trim());
					objObject.ReworkMfgBinID = int.Parse(odrPCS[IV_MRBResultTable.REWORKMFGBINID_FLD].ToString().Trim());
					objObject.ScrapBinID = int.Parse(odrPCS[IV_MRBResultTable.SCRAPBINID_FLD].ToString().Trim());
					objObject.ReworkPurBinID = int.Parse(odrPCS[IV_MRBResultTable.REWORKPURBINID_FLD].ToString().Trim());
					objObject.UseAsIsLocID = int.Parse(odrPCS[IV_MRBResultTable.USEASISLOCID_FLD].ToString().Trim());
					objObject.RTVLocID = int.Parse(odrPCS[IV_MRBResultTable.RTVLOCID_FLD].ToString().Trim());
					objObject.RTVReplaceLocID = int.Parse(odrPCS[IV_MRBResultTable.RTVREPLACELOCID_FLD].ToString().Trim());
					objObject.RTVReworkLocID = int.Parse(odrPCS[IV_MRBResultTable.RTVREWORKLOCID_FLD].ToString().Trim());
					objObject.ReworkMfgLocID = int.Parse(odrPCS[IV_MRBResultTable.REWORKMFGLOCID_FLD].ToString().Trim());
					objObject.ScrapLocID = int.Parse(odrPCS[IV_MRBResultTable.SCRAPLOCID_FLD].ToString().Trim());
					objObject.ReworkPurLocID = int.Parse(odrPCS[IV_MRBResultTable.REWORKPURLOCID_FLD].ToString().Trim());
					objObject.StockUMID = int.Parse(odrPCS[IV_MRBResultTable.STOCKUMID_FLD].ToString().Trim());
					objObject.ProductID = int.Parse(odrPCS[IV_MRBResultTable.PRODUCTID_FLD].ToString().Trim());

				}		
				return objObject;					
			}
			catch(OleDbException ex)
			{			
				throw new PCSDBException(ErrorCode.ERROR_DB, METHOD_NAME,ex);
			}			

			catch (Exception ex) 
			{
				throw new PCSDBException(ErrorCode.OTHER_ERROR, METHOD_NAME, ex);
			}

			finally 
			{
				if (oconPCS!=null) 
				{
					if (oconPCS.State != ConnectionState.Closed) 
					{
						oconPCS.Close();
					}
				}
			}
		}


		///    <summary>
		///       This method uses to add data to IV_MRBResult
		///    </summary>
		///    <Inputs>
		///        IV_MRBResultVO       
		///    </Inputs>
		///    <Returns>
		///       void
		///    </Returns>
		///    <History>
		///       Friday, July 29, 2005
		///    </History>
		
	
		public void Update(object pobjObjecVO)
		{
			const string METHOD_NAME = THIS + ".Update()";

			IV_MRBResultVO objObject = (IV_MRBResultVO) pobjObjecVO;
			

			//prepare value for parameters
			OleDbConnection oconPCS =null;
			OleDbCommand ocmdPCS = null;
			try 
			{
				string strSql = String.Empty;
				
				oconPCS = new OleDbConnection(Utils.Instance.OleDbConnectionString);
				ocmdPCS = new OleDbCommand(strSql, oconPCS);
				strSql=	"UPDATE IV_MRBResult SET "
					+ IV_MRBResultTable.MRBRESULTID_FLD + "=   ?" + ","
					+ IV_MRBResultTable.MRBNO_FLD + "=   ?" + ","
					+ IV_MRBResultTable.CCNID_FLD + "=   ?" + ","
					+ IV_MRBResultTable.LOT_FLD + "=   ?" + ","
					+ IV_MRBResultTable.SERIAL_FLD + "=   ?" + ","
					+ IV_MRBResultTable.LOCATIONID_FLD + "=   ?" + ","
					+ IV_MRBResultTable.BINID_FLD + "=   ?" + ","
					+ IV_MRBResultTable.POSTDATE_FLD + "=   ?" + ","
					+ IV_MRBResultTable.COMMENT_FLD + "=   ?" + ","
					+ IV_MRBResultTable.USEASISQUANTITY_FLD + "=   ?" + ","
					+ IV_MRBResultTable.RTVQUANTITY_FLD + "=   ?" + ","
					+ IV_MRBResultTable.RTVREPLACEQUANTITY_FLD + "=   ?" + ","
					+ IV_MRBResultTable.RTVREWORKQUANTITY_FLD + "=   ?" + ","
					+ IV_MRBResultTable.REWORKMFGQUANTITY_FLD + "=   ?" + ","
					+ IV_MRBResultTable.SCRAPQUANTITY_FLD + "=   ?" + ","
					+ IV_MRBResultTable.USEASISBINID_FLD + "=   ?" + ","
					+ IV_MRBResultTable.RTVBINID_FLD + "=   ?" + ","
					+ IV_MRBResultTable.RTVREPLACEBINID_FLD + "=   ?" + ","
					+ IV_MRBResultTable.RTVREWORKBINID_FLD + "=   ?" + ","
					+ IV_MRBResultTable.REWORKMFGBINID_FLD + "=   ?" + ","
					+ IV_MRBResultTable.SCRAPBINID_FLD + "=   ?" + ","
					+ IV_MRBResultTable.REWORKPURBINID_FLD + "=   ?" + ","
					+ IV_MRBResultTable.USEASISLOCID_FLD + "=   ?" + ","
					+ IV_MRBResultTable.RTVLOCID_FLD + "=   ?" + ","
					+ IV_MRBResultTable.RTVREPLACELOCID_FLD + "=   ?" + ","
					+ IV_MRBResultTable.RTVREWORKLOCID_FLD + "=   ?" + ","
					+ IV_MRBResultTable.REWORKMFGLOCID_FLD + "=   ?" + ","
					+ IV_MRBResultTable.SCRAPLOCID_FLD + "=   ?" + ","
					+ IV_MRBResultTable.REWORKPURLOCID_FLD + "=   ?" + ","
					+ IV_MRBResultTable.STOCKUMID_FLD + "=   ?" + ","
					+ IV_MRBResultTable.PRODUCTID_FLD + "=  ?"
					+" WHERE " + IV_MRBResultTable.MASTERLOCATIONID_FLD + "= ?";

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_MRBResultTable.MRBRESULTID_FLD, OleDbType.Integer));
				ocmdPCS.Parameters[IV_MRBResultTable.MRBRESULTID_FLD].Value = objObject.MRBResultID;

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_MRBResultTable.MRBNO_FLD, OleDbType.VarWChar));
				ocmdPCS.Parameters[IV_MRBResultTable.MRBNO_FLD].Value = objObject.MRBNo;

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_MRBResultTable.CCNID_FLD, OleDbType.Integer));
				ocmdPCS.Parameters[IV_MRBResultTable.CCNID_FLD].Value = objObject.CCNID;

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_MRBResultTable.LOT_FLD, OleDbType.VarWChar));
				ocmdPCS.Parameters[IV_MRBResultTable.LOT_FLD].Value = objObject.Lot;

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_MRBResultTable.SERIAL_FLD, OleDbType.VarWChar));
				ocmdPCS.Parameters[IV_MRBResultTable.SERIAL_FLD].Value = objObject.Serial;

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_MRBResultTable.LOCATIONID_FLD, OleDbType.Integer));
				ocmdPCS.Parameters[IV_MRBResultTable.LOCATIONID_FLD].Value = objObject.LocationID;

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_MRBResultTable.BINID_FLD, OleDbType.Integer));
				ocmdPCS.Parameters[IV_MRBResultTable.BINID_FLD].Value = objObject.BinID;

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_MRBResultTable.POSTDATE_FLD, OleDbType.Date));
				ocmdPCS.Parameters[IV_MRBResultTable.POSTDATE_FLD].Value = objObject.PostDate;

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_MRBResultTable.COMMENT_FLD, OleDbType.VarWChar));
				ocmdPCS.Parameters[IV_MRBResultTable.COMMENT_FLD].Value = objObject.Comment;

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_MRBResultTable.USEASISQUANTITY_FLD, OleDbType.Decimal));
				ocmdPCS.Parameters[IV_MRBResultTable.USEASISQUANTITY_FLD].Value = objObject.UseAsIsQuantity;

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_MRBResultTable.RTVQUANTITY_FLD, OleDbType.Decimal));
				ocmdPCS.Parameters[IV_MRBResultTable.RTVQUANTITY_FLD].Value = objObject.RTVQuantity;

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_MRBResultTable.RTVREPLACEQUANTITY_FLD, OleDbType.Decimal));
				ocmdPCS.Parameters[IV_MRBResultTable.RTVREPLACEQUANTITY_FLD].Value = objObject.RTVReplaceQuantity;

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_MRBResultTable.RTVREWORKQUANTITY_FLD, OleDbType.Decimal));
				ocmdPCS.Parameters[IV_MRBResultTable.RTVREWORKQUANTITY_FLD].Value = objObject.RTVReworkQuantity;

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_MRBResultTable.REWORKMFGQUANTITY_FLD, OleDbType.Decimal));
				ocmdPCS.Parameters[IV_MRBResultTable.REWORKMFGQUANTITY_FLD].Value = objObject.ReworkMfgQuantity;

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_MRBResultTable.SCRAPQUANTITY_FLD, OleDbType.Decimal));
				ocmdPCS.Parameters[IV_MRBResultTable.SCRAPQUANTITY_FLD].Value = objObject.ScrapQuantity;

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_MRBResultTable.USEASISBINID_FLD, OleDbType.Integer));
				ocmdPCS.Parameters[IV_MRBResultTable.USEASISBINID_FLD].Value = objObject.UseAsIsBinID;

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_MRBResultTable.RTVBINID_FLD, OleDbType.Integer));
				ocmdPCS.Parameters[IV_MRBResultTable.RTVBINID_FLD].Value = objObject.RTVBinID;

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_MRBResultTable.RTVREPLACEBINID_FLD, OleDbType.Integer));
				ocmdPCS.Parameters[IV_MRBResultTable.RTVREPLACEBINID_FLD].Value = objObject.RTVReplaceBinID;

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_MRBResultTable.RTVREWORKBINID_FLD, OleDbType.Integer));
				ocmdPCS.Parameters[IV_MRBResultTable.RTVREWORKBINID_FLD].Value = objObject.RTVReworkBinID;

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_MRBResultTable.REWORKMFGBINID_FLD, OleDbType.Integer));
				ocmdPCS.Parameters[IV_MRBResultTable.REWORKMFGBINID_FLD].Value = objObject.ReworkMfgBinID;

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_MRBResultTable.SCRAPBINID_FLD, OleDbType.Integer));
				ocmdPCS.Parameters[IV_MRBResultTable.SCRAPBINID_FLD].Value = objObject.ScrapBinID;

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_MRBResultTable.REWORKPURBINID_FLD, OleDbType.Integer));
				ocmdPCS.Parameters[IV_MRBResultTable.REWORKPURBINID_FLD].Value = objObject.ReworkPurBinID;

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_MRBResultTable.USEASISLOCID_FLD, OleDbType.Integer));
				ocmdPCS.Parameters[IV_MRBResultTable.USEASISLOCID_FLD].Value = objObject.UseAsIsLocID;

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_MRBResultTable.RTVLOCID_FLD, OleDbType.Integer));
				ocmdPCS.Parameters[IV_MRBResultTable.RTVLOCID_FLD].Value = objObject.RTVLocID;

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_MRBResultTable.RTVREPLACELOCID_FLD, OleDbType.Integer));
				ocmdPCS.Parameters[IV_MRBResultTable.RTVREPLACELOCID_FLD].Value = objObject.RTVReplaceLocID;

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_MRBResultTable.RTVREWORKLOCID_FLD, OleDbType.Integer));
				ocmdPCS.Parameters[IV_MRBResultTable.RTVREWORKLOCID_FLD].Value = objObject.RTVReworkLocID;

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_MRBResultTable.REWORKMFGLOCID_FLD, OleDbType.Integer));
				ocmdPCS.Parameters[IV_MRBResultTable.REWORKMFGLOCID_FLD].Value = objObject.ReworkMfgLocID;

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_MRBResultTable.SCRAPLOCID_FLD, OleDbType.Integer));
				ocmdPCS.Parameters[IV_MRBResultTable.SCRAPLOCID_FLD].Value = objObject.ScrapLocID;

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_MRBResultTable.REWORKPURLOCID_FLD, OleDbType.Integer));
				ocmdPCS.Parameters[IV_MRBResultTable.REWORKPURLOCID_FLD].Value = objObject.ReworkPurLocID;

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_MRBResultTable.STOCKUMID_FLD, OleDbType.Integer));
				ocmdPCS.Parameters[IV_MRBResultTable.STOCKUMID_FLD].Value = objObject.StockUMID;

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_MRBResultTable.PRODUCTID_FLD, OleDbType.Integer));
				ocmdPCS.Parameters[IV_MRBResultTable.PRODUCTID_FLD].Value = objObject.ProductID;

				ocmdPCS.Parameters.Add(new OleDbParameter(IV_MRBResultTable.MASTERLOCATIONID_FLD, OleDbType.Integer));
				ocmdPCS.Parameters[IV_MRBResultTable.MASTERLOCATIONID_FLD].Value = objObject.MasterLocationID;


				ocmdPCS.CommandText = strSql;
				ocmdPCS.Connection.Open();
				ocmdPCS.ExecuteNonQuery();	
			}
			catch(OleDbException ex)
			{
				if (ex.Errors[1].NativeError == ErrorCode.SQLDUPLICATE_KEYCODE)
				{
																   
					throw new PCSDBException(ErrorCode.DUPLICATE_KEY, METHOD_NAME, ex);				
				}
				else
				{
					throw new PCSDBException(ErrorCode.ERROR_DB, METHOD_NAME,ex);
				}
			}			

			catch(InvalidOperationException ex)
			{
				throw new PCSDBException(ErrorCode.ERROR_DB, METHOD_NAME,ex);
			}
			catch (Exception ex) 
			{
				throw new PCSDBException(ErrorCode.OTHER_ERROR, METHOD_NAME, ex);
			}

			finally 
			{
				if (oconPCS!=null) 
				{
					if (oconPCS.State != ConnectionState.Closed) 
					{
						oconPCS.Close();
					}
				}
			}

		}


		///    <summary>
		///       This method uses to add data to IV_MRBResult
		///    </summary>
		///    <Inputs>
		///        IV_MRBResultVO       
		///    </Inputs>
		///    <Returns>
		///       void
		///    </Returns>
		///    <History>
		///       Friday, July 29, 2005
		///    </History>

		public DataSet List()
		{
			const string METHOD_NAME = THIS + ".List()";
			DataSet dstPCS = new DataSet();
			
		

			OleDbConnection oconPCS =null;
			OleDbCommand ocmdPCS = null;
			try 
			{
				string strSql = String.Empty;
				
				strSql=	"SELECT "
					+ IV_MRBResultTable.MASTERLOCATIONID_FLD + ","
					+ IV_MRBResultTable.MRBRESULTID_FLD + ","
					+ IV_MRBResultTable.MRBNO_FLD + ","
					+ IV_MRBResultTable.CCNID_FLD + ","
					+ IV_MRBResultTable.LOT_FLD + ","
					+ IV_MRBResultTable.SERIAL_FLD + ","
					+ IV_MRBResultTable.LOCATIONID_FLD + ","
					+ IV_MRBResultTable.BINID_FLD + ","
					+ IV_MRBResultTable.POSTDATE_FLD + ","
					+ IV_MRBResultTable.COMMENT_FLD + ","
					+ IV_MRBResultTable.USEASISQUANTITY_FLD + ","
					+ IV_MRBResultTable.RTVQUANTITY_FLD + ","
					+ IV_MRBResultTable.RTVREPLACEQUANTITY_FLD + ","
					+ IV_MRBResultTable.RTVREWORKQUANTITY_FLD + ","
					+ IV_MRBResultTable.REWORKMFGQUANTITY_FLD + ","
					+ IV_MRBResultTable.SCRAPQUANTITY_FLD + ","
					+ IV_MRBResultTable.USEASISBINID_FLD + ","
					+ IV_MRBResultTable.RTVBINID_FLD + ","
					+ IV_MRBResultTable.RTVREPLACEBINID_FLD + ","
					+ IV_MRBResultTable.RTVREWORKBINID_FLD + ","
					+ IV_MRBResultTable.REWORKMFGBINID_FLD + ","
					+ IV_MRBResultTable.SCRAPBINID_FLD + ","
					+ IV_MRBResultTable.REWORKPURBINID_FLD + ","
					+ IV_MRBResultTable.USEASISLOCID_FLD + ","
					+ IV_MRBResultTable.RTVLOCID_FLD + ","
					+ IV_MRBResultTable.RTVREPLACELOCID_FLD + ","
					+ IV_MRBResultTable.RTVREWORKLOCID_FLD + ","
					+ IV_MRBResultTable.REWORKMFGLOCID_FLD + ","
					+ IV_MRBResultTable.SCRAPLOCID_FLD + ","
					+ IV_MRBResultTable.REWORKPURLOCID_FLD + ","
					+ IV_MRBResultTable.STOCKUMID_FLD + ","
					+ IV_MRBResultTable.PRODUCTID_FLD
					+ " FROM " + IV_MRBResultTable.TABLE_NAME;
				
				oconPCS = new OleDbConnection(Utils.Instance.OleDbConnectionString);
				ocmdPCS = new OleDbCommand(strSql, oconPCS);
				ocmdPCS.Connection.Open();
				
				OleDbDataAdapter odadPCS = new OleDbDataAdapter(ocmdPCS);
				odadPCS.Fill(dstPCS,IV_MRBResultTable.TABLE_NAME);

				return dstPCS;
			}
			catch(OleDbException ex)
			{
				throw new PCSDBException(ErrorCode.ERROR_DB, METHOD_NAME,ex);
			}			
			catch (Exception ex) 
			{
				throw new PCSDBException(ErrorCode.OTHER_ERROR, METHOD_NAME, ex);
			}

			finally 
			{
				if (oconPCS!=null) 
				{
					if (oconPCS.State != ConnectionState.Closed) 
					{
						oconPCS.Close();
					}
				}
			}


		}


		///    <summary>
		///       This method uses to add data to IV_MRBResult
		///    </summary>
		///    <Inputs>
		///        IV_MRBResultVO       
		///    </Inputs>
		///    <Returns>
		///       void
		///    </Returns>
		///    <History>
		///       Friday, July 29, 2005
		///    </History>
		
		public void UpdateDataSet(DataSet pdstData)
		{
			const string METHOD_NAME = THIS + ".UpdateDataSet()";
			string strSql;
			OleDbConnection oconPCS =null;
			OleDbCommandBuilder odcbPCS ;
			OleDbDataAdapter odadPCS = new OleDbDataAdapter();

			try
			{
				strSql=	"SELECT "
					+ IV_MRBResultTable.MASTERLOCATIONID_FLD + ","
					+ IV_MRBResultTable.MRBRESULTID_FLD + ","
					+ IV_MRBResultTable.MRBNO_FLD + ","
					+ IV_MRBResultTable.CCNID_FLD + ","
					+ IV_MRBResultTable.LOT_FLD + ","
					+ IV_MRBResultTable.SERIAL_FLD + ","
					+ IV_MRBResultTable.LOCATIONID_FLD + ","
					+ IV_MRBResultTable.BINID_FLD + ","
					+ IV_MRBResultTable.POSTDATE_FLD + ","
					+ IV_MRBResultTable.COMMENT_FLD + ","
					+ IV_MRBResultTable.USEASISQUANTITY_FLD + ","
					+ IV_MRBResultTable.RTVQUANTITY_FLD + ","
					+ IV_MRBResultTable.RTVREPLACEQUANTITY_FLD + ","
					+ IV_MRBResultTable.RTVREWORKQUANTITY_FLD + ","
					+ IV_MRBResultTable.REWORKMFGQUANTITY_FLD + ","
					+ IV_MRBResultTable.SCRAPQUANTITY_FLD + ","
					+ IV_MRBResultTable.USEASISBINID_FLD + ","
					+ IV_MRBResultTable.RTVBINID_FLD + ","
					+ IV_MRBResultTable.RTVREPLACEBINID_FLD + ","
					+ IV_MRBResultTable.RTVREWORKBINID_FLD + ","
					+ IV_MRBResultTable.REWORKMFGBINID_FLD + ","
					+ IV_MRBResultTable.SCRAPBINID_FLD + ","
					+ IV_MRBResultTable.REWORKPURBINID_FLD + ","
					+ IV_MRBResultTable.USEASISLOCID_FLD + ","
					+ IV_MRBResultTable.RTVLOCID_FLD + ","
					+ IV_MRBResultTable.RTVREPLACELOCID_FLD + ","
					+ IV_MRBResultTable.RTVREWORKLOCID_FLD + ","
					+ IV_MRBResultTable.REWORKMFGLOCID_FLD + ","
					+ IV_MRBResultTable.SCRAPLOCID_FLD + ","
					+ IV_MRBResultTable.REWORKPURLOCID_FLD + ","
					+ IV_MRBResultTable.STOCKUMID_FLD + ","
					+ IV_MRBResultTable.PRODUCTID_FLD 
					+ "  FROM " + IV_MRBResultTable.TABLE_NAME;

				
				oconPCS = new OleDbConnection(Utils.Instance.OleDbConnectionString);
				odadPCS.SelectCommand = new OleDbCommand(strSql, oconPCS);
				odcbPCS = new OleDbCommandBuilder(odadPCS);
				pdstData.EnforceConstraints = false;
				odadPCS.Update(pdstData,IV_MRBResultTable.TABLE_NAME);

			}
			catch(OleDbException ex)
			{
				if (ex.Errors[1].NativeError == ErrorCode.SQLDUPLICATE_KEYCODE)
				{
																   
					throw new PCSDBException(ErrorCode.DUPLICATE_KEY, METHOD_NAME, ex);				
				}
				else if (ex.Errors[1].NativeError == ErrorCode.SQLCASCADE_PREVENT_KEYCODE)
				{

					throw new PCSDBException(ErrorCode.CASCADE_DELETE_PREVENT, METHOD_NAME, ex);				
				}
				
				else
				{
					throw new PCSDBException(ErrorCode.ERROR_DB, METHOD_NAME,ex);
				}
			}			

			catch(InvalidOperationException ex)
			{
				throw new PCSDBException(ErrorCode.ERROR_DB, METHOD_NAME,ex);
			}
			catch (Exception ex) 
			{
				throw new PCSDBException(ErrorCode.OTHER_ERROR, METHOD_NAME, ex);
			}

			finally 
			{
				if (oconPCS!=null) 
				{
					if (oconPCS.State != ConnectionState.Closed) 
					{
						oconPCS.Close();
					}
				}
			}

		}

		
		///    <summary>
		///       This method uses to add data to IV_MRBResult
		///    </summary>
		///    <Inputs>
		///        IV_MRBResultVO       
		///    </Inputs>
		///    <Returns>
		///       void
		///    </Returns>
		///    <History>
		///       Friday, July 29, 2005
		///    </History>

		public DataRow GetMRBResultInforByID(int pintMRBResultID)
		{
			const string METHOD_NAME = THIS + ".GetMRBResultInforByID()";
			DataSet dstPCS = new DataSet();
			
			OleDbConnection oconPCS =null;
			OleDbCommand ocmdPCS = null;
			try 
			{
				string strSql = "SELECT "
					+ IV_MRBResultTable.MRBNO_FLD + ","
					+ IV_MRBResultTable.LOT_FLD + ","
					+ IV_MRBResultTable.SERIAL_FLD + ","
					+ IV_MRBResultTable.POSTDATE_FLD + ","
					+ IV_MRBResultTable.COMMENT_FLD + ","
					+ IV_MRBResultTable.USEASISQUANTITY_FLD + ","
					+ IV_MRBResultTable.RTVQUANTITY_FLD + ","
					+ IV_MRBResultTable.RTVREPLACEQUANTITY_FLD + ","
					+ IV_MRBResultTable.RTVREWORKQUANTITY_FLD + ","
					+ IV_MRBResultTable.REWORKMFGQUANTITY_FLD + ","
					+ IV_MRBResultTable.REWORKPURQUANTITY_FLD + ","
					+ IV_MRBResultTable.SCRAPQUANTITY_FLD + ","
					+ IV_MRBResultTable.PRODUCTID_FLD + "," 
					+ "(SELECT " + MST_MasterLocationTable.CODE_FLD + " FROM " + MST_MasterLocationTable.TABLE_NAME + " WHERE " + MST_MasterLocationTable.MASTERLOCATIONID_FLD + " = MRB." + IV_MRBResultTable.MASTERLOCATIONID_FLD + ") as " + IV_MRBResultTable.MASTERLOCATIONID_FLD + ","
					+ "(SELECT " + MST_LocationTable.CODE_FLD + " FROM " + MST_LocationTable.TABLE_NAME + " WHERE " + MST_LocationTable.LOCATIONID_FLD + " = MRB." + IV_MRBResultTable.LOCATIONID_FLD + ") as " + MST_LocationTable.LOCATIONID_FLD + ","
					+ "(SELECT " + MST_BINTable.CODE_FLD + " FROM " + MST_BINTable.TABLE_NAME + " WHERE " + MST_BINTable.BINID_FLD + " = MRB." + IV_MRBResultTable.BINID_FLD + ") as " + MST_BINTable.BINID_FLD + ","
					+ "(SELECT " + MST_LocationTable.CODE_FLD + " FROM " + MST_LocationTable.TABLE_NAME + " WHERE " + MST_LocationTable.LOCATIONID_FLD + " = MRB." + IV_MRBResultTable.USEASISLOCID_FLD + ") as " + IV_MRBResultTable.USEASISLOCID_FLD + ","
					+ "(SELECT " + MST_LocationTable.CODE_FLD + " FROM " + MST_LocationTable.TABLE_NAME + " WHERE " + MST_LocationTable.LOCATIONID_FLD + " = MRB." + IV_MRBResultTable.RTVLOCID_FLD + ") as " + IV_MRBResultTable.RTVLOCID_FLD + ","
					+ "(SELECT " + MST_LocationTable.CODE_FLD + " FROM " + MST_LocationTable.TABLE_NAME + " WHERE " + MST_LocationTable.LOCATIONID_FLD + " = MRB." + IV_MRBResultTable.RTVREPLACELOCID_FLD + ") as " + IV_MRBResultTable.RTVREPLACELOCID_FLD + ","
					+ "(SELECT " + MST_LocationTable.CODE_FLD + " FROM " + MST_LocationTable.TABLE_NAME + " WHERE " + MST_LocationTable.LOCATIONID_FLD + " = MRB." + IV_MRBResultTable.RTVREWORKLOCID_FLD + ") as " + IV_MRBResultTable.RTVREWORKLOCID_FLD + ","
					+ "(SELECT " + MST_LocationTable.CODE_FLD + " FROM " + MST_LocationTable.TABLE_NAME + " WHERE " + MST_LocationTable.LOCATIONID_FLD + " = MRB." + IV_MRBResultTable.REWORKMFGLOCID_FLD + ") as " + IV_MRBResultTable.REWORKMFGLOCID_FLD + ","
					+ "(SELECT " + MST_LocationTable.CODE_FLD + " FROM " + MST_LocationTable.TABLE_NAME + " WHERE " + MST_LocationTable.LOCATIONID_FLD + " = MRB." + IV_MRBResultTable.REWORKPURLOCID_FLD + ") as " + IV_MRBResultTable.REWORKPURLOCID_FLD + ","
					+ "(SELECT " + MST_LocationTable.CODE_FLD + " FROM " + MST_LocationTable.TABLE_NAME + " WHERE " + MST_LocationTable.LOCATIONID_FLD + " = MRB." + IV_MRBResultTable.SCRAPLOCID_FLD + ") as " + IV_MRBResultTable.SCRAPLOCID_FLD + ","
					+ "(SELECT " + MST_BINTable.CODE_FLD + " FROM " + MST_BINTable.TABLE_NAME + " WHERE " + MST_BINTable.BINID_FLD + " = MRB." + IV_MRBResultTable.USEASISBINID_FLD + ") as " + IV_MRBResultTable.USEASISBINID_FLD + ","
					+ "(SELECT " + MST_BINTable.CODE_FLD + " FROM " + MST_BINTable.TABLE_NAME + " WHERE " + MST_BINTable.BINID_FLD + " = MRB." + IV_MRBResultTable.RTVBINID_FLD + ") as " + IV_MRBResultTable.RTVBINID_FLD + ","
					+ "(SELECT " + MST_BINTable.CODE_FLD + " FROM " + MST_BINTable.TABLE_NAME + " WHERE " + MST_BINTable.BINID_FLD + " = MRB." + IV_MRBResultTable.RTVREPLACEBINID_FLD + ") as " + IV_MRBResultTable.RTVREPLACEBINID_FLD + ","
					+ "(SELECT " + MST_BINTable.CODE_FLD + " FROM " + MST_BINTable.TABLE_NAME + " WHERE " + MST_BINTable.BINID_FLD + " = MRB." + IV_MRBResultTable.RTVREWORKBINID_FLD + ") as " + IV_MRBResultTable.RTVREWORKBINID_FLD + ","
					+ "(SELECT " + MST_BINTable.CODE_FLD + " FROM " + MST_BINTable.TABLE_NAME + " WHERE " + MST_BINTable.BINID_FLD + " = MRB." + IV_MRBResultTable.REWORKMFGBINID_FLD + ") as " + IV_MRBResultTable.REWORKMFGBINID_FLD + ","
					+ "(SELECT " + MST_BINTable.CODE_FLD + " FROM " + MST_BINTable.TABLE_NAME + " WHERE " + MST_BINTable.BINID_FLD + " = MRB." + IV_MRBResultTable.REWORKPURBINID_FLD + ") as " + IV_MRBResultTable.REWORKPURBINID_FLD + ","
					+ "(SELECT " + MST_BINTable.CODE_FLD + " FROM " + MST_BINTable.TABLE_NAME + " WHERE " + MST_BINTable.BINID_FLD + " = MRB." + IV_MRBResultTable.SCRAPBINID_FLD + ") as " + IV_MRBResultTable.SCRAPBINID_FLD
					+ " FROM " + IV_MRBResultTable.TABLE_NAME + " MRB "
					+ " WHERE MRB." + IV_MRBResultTable.MRBRESULTID_FLD + "=" + pintMRBResultID;
				
				oconPCS = new OleDbConnection(Utils.Instance.OleDbConnectionString);
				ocmdPCS = new OleDbCommand(strSql, oconPCS);
				ocmdPCS.Connection.Open();
				
				OleDbDataAdapter odadPCS = new OleDbDataAdapter(ocmdPCS);
				odadPCS.Fill(dstPCS,IV_MRBResultTable.TABLE_NAME);
				oconPCS.Close();

				if (dstPCS.Tables[0].Rows.Count > 0)
				{
					return dstPCS.Tables[0].Rows[0];
				}
				return null;
			}
			catch(OleDbException ex)
			{
				throw new PCSDBException(ErrorCode.ERROR_DB, METHOD_NAME,ex);
			}			
			catch (Exception ex) 
			{
				throw new PCSDBException(ErrorCode.OTHER_ERROR, METHOD_NAME, ex);
			}

			finally 
			{
				if (oconPCS!=null) 
				{
					if (oconPCS.State != ConnectionState.Closed) 
					{
						oconPCS.Close();
					}
				}
			}
		}
	}
}
